<?php

require_once(WSB_MODULES_PATH .'sherpa/models/BaseGateway.php');
require_once(WSB_MODULES_PATH .'sherpa/models/Icons.php');
require_once(WSB_MODULES_PATH .'sherpa/models/Icon.php');

class Sherpa_Model_IconGateway extends Sherpa_Model_BaseGateway
{

	/**
	 * @param integer $parentProductId
	 * @param integer $languageId
	 * @return Sherpa_Model_Icons
	 */
	public function fetchParentProductIcons($parentProductId, $languageId)
	{
		$select = $this->getDbSelect();
		$select->from(array('i' => 'sherpa_icons'));
		$select->join(array('pti' => 'sherpa_productToIcon'), 'i.id = pti.iconId', array());
		$select->where('i.languageId = ?', $languageId);
		$select->where('pti.parentProductId = ?', $parentProductId);
		$select->order('pti.sort ASC');
		$stmt = $select->query();
		if($this->useModels()) {
			return new Sherpa_Model_Icons($stmt->fetchAll());
		} else {
			return $stmt->fetchAll();
		}
	}

}
